package com.useeinfo.oa.modules.base.thread;

import com.useeinfo.framework.sugar.data.QueryParam;
import com.useeinfo.oa.modules.base.biz.MessageBiz;
import com.useeinfo.oa.modules.base.biz.PlanMessageSendBiz;
import com.useeinfo.oa.modules.base.entity.PlanMessageSend;
import com.useeinfo.oa.modules.security.biz.UserDeviceBiz;
import com.useeinfo.oa.modules.security.entity.UserDevice;
import com.useeinfo.oa.modules.threadUtil.ThreadUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: xudong.sun
 * @Date: 2019/1/18 09:38
 * @Description:
 */
@Service("PlanMessageSecheduled")
public class PlanMessageSecheduled {

    @Autowired
    private MessageBiz messageBiz;
    @Autowired
    private PlanMessageSendBiz planMessageSendBiz;
    @Autowired

    private final static Logger logger = LoggerFactory.getLogger(PlanMessageSecheduled.class);

    //消息推送
    public void execute() {
        logger.info("开始检查计划消息表");
        List<PlanMessageSend> planMessageSends = planMessageSendBiz.cancelPlanMessage();
        if(CollectionUtils.isNotEmpty(planMessageSends)){
            ThreadUtils.messageSendExecute(messageBiz,planMessageSends);
        }
        logger.info("消息发送成功");
    }
}
